package com.whpost.api.controller.qyh;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.whpost.api.utils.ApiUtils;
import com.whpost.service.entity.tools.ResultInfo;
import com.whpost.service.service.cwqf.HsCzyServices;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/qyh/czy")
public class HsCzyController {

    @Resource
    private HsCzyServices hsCzyServices;

    /**操作员查询
     *
     * @param map
     * @return
     */
    @SaCheckLogin
    @RequestMapping(value ="/query")
    public ResultInfo query(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return hsCzyServices.query(loginId,map);
    }

    /**
     *  操作员存盘
     * @return
     */
    @RequestMapping(value ="/save")
    public ResultInfo save(@RequestParam(value = "wj", required = false) List<MultipartFile> wj,
                           @RequestParam(value = "data", required = false) String data, HttpServletRequest httpServletRequest){
        System.out.println("List<MultipartFile>:"+wj);
        System.out.println("data:"+data);
        String loginId = ApiUtils.getLoginId();
        return hsCzyServices.save(loginId,wj,data);
    }

    /** 操作员删除
     * @param map
     * @return
     */
    @SaCheckLogin
    @RequestMapping(value ="/del")
    public ResultInfo del(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return hsCzyServices.del(loginId,map);
    }

    /**机构查询
     * 前端检索使用
     * @param map
     * @return
     */
    @SaCheckLogin
    @RequestMapping(value ="/jgcx")
    public ResultInfo jgcx(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return hsCzyServices.jgcx(loginId,map);
    }
}
